function [lsRedShock, lsRedParam] = chkredundant(this,varargin)
% chkredundant  Check for redundant shocks and/or parameters.
%
%
% Syntax
% =======
%
%     [RedShocks,RedParams] = chkredundant(M)
%
%
% Input arguments
% ================
%
% * `M` [ model ] - Model object.
%
%
% Output arguments
% =================
%
% * `RedShocks` [ cellstr ] - List of shocks that do not occur in any model
% equation.
%
% * `RedParams` [ cellstr ] - List of parameters that do not occur in any
% model equation.
%
%
% Options
% ========
%
% * `'warning='` [ *`true`* | `false` ] - Throw a warning listing redundant
% shocks and parameters.
%
% * `'chkShocks='` [ *`true`* | `false` ] - Check for redundant shocks.
%
% * `'chkParams='` [ *`true`* | `false` ] - Check for redundant parameters.
%
%
% Description
% ============
%
%
% Example
% ========
%
%

% -IRIS Toolbox.
% -Copyright (c) 2007-2015 IRIS Solutions Team.

opt = passvalopt('model.chkredundant', varargin{:});

%--------------------------------------------------------------------------

nName = length(this.name);
occur = reshape( full(this.occur), ...
    [size(this.occur,1), nName, size(this.occur,2)/nName] );

tZero = this.Shift==0;

lsRedShock([ ]) = { };
if opt.chkshock
    ixShock = any(occur(:,this.nametype==3,tZero), 1);
    lsRedShock = this.name(this.nametype==3);
    lsRedShock = lsRedShock(~ixShock);
end

lsRedParam([ ]) = { };
if opt.chkparam
    ixParam = any(occur(:,this.nametype==4,tZero), 1);
    lsRedParam = this.name(this.nametype==4);
    lsRedParam = lsRedParam(~ixParam);
end

if opt.warning
    if ~isempty(lsRedShock)
        utils.warning('model:chkredundant', ...
            'This shock does not occur in any model equation: %s', ...
            lsRedShock{:});
    end
    if ~isempty(lsRedParam)
        utils.warning('model:chkredundant', ...
            'This parameter does not occur in any model equation: %s', ...
            lsRedParam{:});
    end
end

end